local xiaoji = fk.CreateSkill({
  name = "mini_mou__xiaoji",
})

Fk:loadTranslationTable{
  ["mini_mou__xiaoji"] = "枭姬",
  [":mini_mou__xiaoji"] = "当你失去装备区里的一张牌后，你摸两张牌，然后你可以弃置场上的一张牌。",

  ["#mini_mou__xiaoji-choose"] = "枭姬：你可以弃置场上的一张牌",

  ["$mini_mou__xiaoji1"] = "女子何故学女工？剑出枪舞势如虹！",
  ["$mini_mou__xiaoji2"] = "女子亦可尚战场，一舞剑器动四方！",
}

xiaoji:addEffect(fk.AfterCardsMove, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(xiaoji.name) then return end
    for _, move in ipairs(data) do
      if move.from == player then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip then
            return true
          end
        end
      end
    end
  end,
  trigger_times = function (self, event, target, player, data)
    local i = 0
    for _, move in ipairs(data) do
      if move.from == player then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip then
            i = i + 1
          end
        end
      end
    end

    return i
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:drawCards(player, 2, xiaoji.name)
    if player.dead then return end
    local targets = table.filter(room.alive_players, function (p)
      return #p:getCardIds("ej") > 0
    end)
    if #targets == 0 then return end
    local to = room:askToChoosePlayers(player, {
      targets = targets,
      min_num = 1,
      max_num = 1,
      prompt = "#mini_mou__xiaoji-choose",
      skill_name = xiaoji.name,
      cancelable = true
    })
    if #to == 0 then return end
    to = to[1]
    local card = room:askToChooseCard(player, {
      target = to,
      flag = "ej",
      skill_name = xiaoji.name,
    })
    room:throwCard(card, xiaoji.name, to, player)
  end,
})

return xiaoji
